<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>批量修改索书号</title>
    <meta name="decorator" content="default"/>
    <script>
        $(function () {
            $("tr").mouseover(function () {
                $(this).children().css("background-color", " #00eeee");
            }).mouseout(function () {
                $(this).children().css("background-color", " #ffffff");
            });
        });
        function changeClasscode(obj) {
            var classcode = $(obj).val();
            $("[name='classcode']").each(function () {
                if (obj.id != this.id) {
                    $(this).val(classcode);
                }
            });
        }

        function changePlace(obj){
            var place = $(obj).val();

            place = place.split(":")[0];
            place = place.split("v")[0];

            $("input[name='place']").each(function(){
                var thisVal = $(this).val();
                if (thisVal.indexOf(":") >= 0) {
                    thisVal = ":" + thisVal.split(":")[1];
                } else if (thisVal.indexOf("v") >= 0) {
                    thisVal = "v" + thisVal.split("v")[1];
                }
                $(this).val(place + thisVal);
            });
        }
    </script>
    <style>
        .field { width: 80px; text-align: right; } td { height: 30px; }
    </style>
</head>
<body>
<div style="margin-top: 10px;">
    <form action="${ctx}/book/store/goBatchChangePlace" method="post">
        <input name="classcode" value="${classcode}" style="margin-left: 15px;">
        <button class="btn btn-small">查询</button>
    </form>
</div>
<form:form id="bkStoreForm" action="${ctx}/book/store/batchChangePlace" method="post" class="form-horizontal store_info">
    <input name="temClasscode" value="${classcode}" type="hidden">
    <table id="contentTable" class="table table-striped table-bordered table-condensed">
        <thead>
        <tr>
            <th>索书号</th>
            <th>ISBN</th>
            <th>题名</th>
            <th>著者</th>
            <th>出版社</th>
            <th>出版日期</th>
            <th>价格</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${stores}" var="store" varStatus="st">
            <tr>
                <td>
                    <input name="storeId" value="${store.id}" type="hidden"/>
                    <input id="classcode_${st.index}" name="classcode" value="${store.classcode}"
                           onkeyup="changeClasscode(this);" autocomplete="off" style="width: 80px;">/
                    <input id="place_${st.index}" name="place" value="${store.place}"
                           onkeyup="changePlace(this);" autocomplete="off" style="width: 40px;">
                </td>
                <td>${store.isbn}</td>
                <td>${store.bookname}</td>
                <td>${store.author}</td>
                <td>${store.publisher}</td>
                <td>${store.pubdate}</td>
                <td>${store.price}</td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
    <div class="control-group all">
        <shiro:hasPermission name="book:store:save">
            <a class="btn" style="width:80px;margin-left: 40%;"
               href="javascript:$('#bkStoreForm').submit()">保存</a>
        </shiro:hasPermission>
    </div>
</form:form>
</body>
</html>